<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>location地址栏对象</title>
    <style>
        p{
            text-align: center;
        }
        span{
            color: red;
        }
    </style>
</head>
<body>
    <p>
        注册成功！<span id="time">5</span>秒之后自动跳转到首页...
    </p>
    <script>
        //改变秒数
        let num = 5;
        function showTime(){
            num--;
            if(num<=0){
                //跳转首页
                location.href = "Demo03.html";
            }
           let span = document.getElementById("time");
           span.innerHTML = num;
        }
        //设置定时器，每一秒执行一次showTime()方法
        setInterval("showTime()",1000);
    </script>
</body>
</html>